home *** CD-ROM | disk | FTP | other *** search
Wrap
VERSION 5.00 Begin VB.UserControl axPanel Alignable = -1 'True CanGetFocus = 0 'False ClientHeight = 735 ClientLeft = 0 ClientTop = 0 ClientWidth = 3930 ControlContainer= -1 'True ScaleHeight = 735 ScaleWidth = 3930 ToolboxBitmap = "axPanel.ctx":0000 Begin VB.Timer Timer Enabled = 0 'False Interval = 1000 Left = 3420 Top = 0 End Begin VB.Label lblText BackStyle = 0 'Transparent Caption = "lblText" Height = 195 Left = 1035 TabIndex = 1 Top = 0 Width = 690 End Begin VB.Label lblCaption AutoSize = -1 'True Caption = "lblCaption" Height = 195 Left = 90 TabIndex = 0 Top = 0 Visible = 0 'False Width = 690 End Begin VB.Shape Flooder BorderStyle = 0 'Transparent FillColor = &H00808080& FillStyle = 0 'Solid Height = 330 Index = 0 Left = 1710 Top = 0 Visible = 0 'False Width = 1635 End End Attribute VB_Name = "axPanel" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = True Attribute VB_PredeclaredId = False Attribute VB_Exposed = True Const m_def_BorderStyle = 2 Private m_BorderStyle As Integer, iLast As Integer Private m_caption As String, m_text As String, m_TextAlignment As Integer Private m_TextType As Integer, m_FloodType As Integer, m_FloodPercent As Integer Private m_FloodShowPct As Boolean, m_FloodColor As Long, m_FloodBackColor As Long Private m_BackColor As Long, m_ForeColor As Long Public Enum AxBorderStyles [No Border] = 0 [Single] = 1 [Thin Raised] = 2 [Thick Raised] = 3 [Thin Inset] = 4 [Thick Inset] = 5 [Etched] = 6 [Bump] = 7 End Enum Public Enum TextAlign [LeftTop] = 0 [LeftMiddle] = 1 [LeftBottom] = 2 [CenterTop] = 3 [CenterMiddle] = 4 [CenterBottom] = 5 [RightTop] = 6 [RightMiddle] = 7 [RightBottom] = 8 End Enum Public Enum TextTypes [User Defined] = 0 [Current Date] = 1 [Current Time] = 2 End Enum Public Enum FloodTypes [None] = 0 [LeftToRight] = 1 [RightToLeft] = 2 [TopToBottom] = 3 [BottomToTop] = 4 [Windows95] = 5 End Enum Private Sub Timer_Timer() lblText.Caption = Time End Sub Private Sub UserControl_Initialize() UserControl.Height = 600: UserControl.Width = 2700 End Sub Private Sub UserControl_InitProperties() m_BorderStyle = m_def_BorderStyle m_caption = "" m_TextAlignment = 4: m_text = "axPanel": m_TextType = 0 lblText.Left = 5: lblText.Top = UserControl.Height / 2 m_FloodType = 0 m_FloodPercent = 0 m_FloodShowPct = False m_FloodColor = vbHighlight m_FloodBackColor = vbButtonFace m_BackColor = vbButtonFace m_ForeColor = vbButtonText UserControl.BackColor = m_BackColor lblCaption.BackColor = m_BackColor lblCaption.ForeColor = m_ForeColor lblText.ForeColor = m_ForeColor End Sub 'Load property values from storage Private Sub UserControl_ReadProperties(PropBag As PropertyBag) UserControl.Enabled = PropBag.ReadProperty("Enabled", True) m_BorderStyle = PropBag.ReadProperty("BorderStyle", m_def_BorderStyle) m_caption = PropBag.ReadProperty("Caption", "") Set Font = PropBag.ReadProperty("Font", Ambient.Font) Set lblCaption.Font = Font Set lblText.Font = Font m_text = PropBag.ReadProperty("Text", "") m_TextAlignment = PropBag.ReadProperty("TextAlignment", 0) m_TextType = PropBag.ReadProperty("TextType", 0) m_FloodShowPct = PropBag.ReadProperty("FloodShowPct", False) m_FloodType = PropBag.ReadProperty("FloodType", 0) m_FloodPercent = PropBag.ReadProperty("FloodPercent", 0) m_FloodColor = PropBag.ReadProperty("FloodColor", vbHighlight) m_FloodBackColor = PropBag.ReadProperty("FloodBackColor", vbButtonFace) m_BackColor = PropBag.ReadProperty("BackColor", vbButtonFace) m_ForeColor = PropBag.ReadProperty("ForeColor", vbButtonText) UserControl.BackColor = m_BackColor lblCaption.BackColor = m_BackColor lblCaption.ForeColor = m_ForeColor lblText.ForeColor = m_ForeColor DisplayText If m_FloodType > 0 And m_FloodType <> 5 Then Flooder(0).Visible = True: DrawFlood Else Flooder(0).Visible = False If m_FloodType = 5 Then Flooder(0).Visible = True: ShowBars: DrawFlood If m_caption > "" Then 'UserControl.Cls 'UserControl_Paint lblCaption.Visible = True lblCaption.Caption = " " + m_caption + " " UserControl.Refresh Else lblCaption.Visible = False UserControl.Refresh 'UserControl.Cls 'UserControl_Paint End If End Sub Private Sub UserControl_Resize() If UserControl.Width > 0 And UserControl.Height > 0 Then DisplayText If m_FloodType > 0 And m_FloodType <> 5 Then Flooder(0).Visible = True: DrawFlood Else Flooder(0).Visible = False If m_FloodType = 5 Then ResizeBars DrawFlood 'UserControl.Width = Flooder(Flooder().Count - 1).Left + Flooder(Flooder().Count - 1).Width + 10 End If End If 'UserControl.Refresh End Sub 'Write property values to storage Private Sub UserControl_WriteProperties(PropBag As PropertyBag) Call PropBag.WriteProperty("Enabled", UserControl.Enabled, True) Call PropBag.WriteProperty("BorderStyle", m_BorderStyle, m_def_BorderStyle) Call PropBag.WriteProperty("Caption", m_caption, "") Call PropBag.WriteProperty("Font", Font, Ambient.Font) Call PropBag.WriteProperty("Text", Text, "") Call PropBag.WriteProperty("TextAlignment", m_TextAlignment, 0) Call PropBag.WriteProperty("TextType", m_TextType, 0) Call PropBag.WriteProperty("FloodShowPct", m_FloodShowPct, False) Call PropBag.WriteProperty("FloodType", m_FloodType, 0) Call PropBag.WriteProperty("FloodPercent", m_FloodPercent, 0) Call PropBag.WriteProperty("FloodColor", m_FloodColor, vbHighlight) Call PropBag.WriteProperty("FloodBackColor", m_FloodBackColor, vbButtonFace) Call PropBag.WriteProperty("BackColor", m_BackColor, vbButtonFace) Call PropBag.WriteProperty("ForeColor", m_ForeColor, vbButtonText) End Sub Private Sub UserControl_Paint() Dim di As Long Dim rc As RECT 'draw outside border di = GetClientRect(UserControl.hwnd, rc) If m_caption > "" Then rc.Top = rc.Top + 5 End If Select Case m_BorderStyle Case [No Border] Case [Single] di = DrawEdge(UserControl.hDC, rc, BDR_RAISEDOUTER, BF_RECT Or BF_MONO) Case [Thin Raised] di = DrawEdge(UserControl.hDC, rc, BDR_RAISEDINNER, BF_TOPLEFT) di = DrawEdge(UserControl.hDC, rc, BDR_RAISEDOUTER, BF_BOTTOMRIGHT) Case [Thick Raised] di = DrawEdge(UserControl.hDC, rc, EDGE_RAISED, BF_TOPLEFT) di = DrawEdge(UserControl.hDC, rc, EDGE_RAISED, BF_BOTTOMRIGHT) Case [Thin Inset] di = DrawEdge(UserControl.hDC, rc, BDR_SUNKENINNER, BF_TOPLEFT) di = DrawEdge(UserControl.hDC, rc, BDR_SUNKENOUTER, BF_BOTTOMRIGHT) Case [Thick Inset] di = DrawEdge(UserControl.hDC, rc, EDGE_SUNKEN, BF_TOPLEFT) di = DrawEdge(UserControl.hDC, rc, EDGE_SUNKEN, BF_BOTTOMRIGHT) Case [Etched] di = DrawEdge(UserControl.hDC, rc, EDGE_ETCHED, BF_TOPLEFT) di = DrawEdge(UserControl.hDC, rc, EDGE_ETCHED, BF_BOTTOMRIGHT) Case [Bump] di = DrawEdge(UserControl.hDC, rc, EDGE_BUMP, BF_TOPLEFT) di = DrawEdge(UserControl.hDC, rc, EDGE_BUMP, BF_BOTTOMRIGHT) End Select 'If m_FloodType > 0 Then DrawFlood End Sub Public Property Get BorderStyle() As AxBorderStyles Attribute BorderStyle.VB_Description = "Returns/sets the border style for an object" BorderStyle = m_BorderStyle End Property Public Property Let BorderStyle(ByVal New_BorderStyle As AxBorderStyles) If Not (m_BorderStyle = New_BorderStyle) Then m_BorderStyle = New_BorderStyle If m_caption > "" Then 'UserControl.Cls 'UserControl_Paint lblCaption.Visible = True lblCaption.Caption = " " + m_caption + " " UserControl.Refresh Else lblCaption.Visible = False 'UserControl.Cls 'UserControl_Paint UserControl.Refresh End If End If PropertyChanged "BorderStyle" End Property Public Sub ShowAbout() Attribute ShowAbout.VB_Description = "Show the about box for the control" Attribute ShowAbout.VB_UserMemId = -552 frmAbout.Show vbModal End Sub 'WARNING! DO NOT REMOVE OR MODIFY THE FOLLOWING COMMENTED LINES! 'MappingInfo=UserControl,UserControl,-1,Enabled Public Property Get Enabled() As Boolean Attribute Enabled.VB_Description = "Returns/sets a value that detemines whether an object can respond to user-generated events" Enabled = UserControl.Enabled End Property Public Property Let Enabled(ByVal New_Enabled As Boolean) UserControl.Enabled() = New_Enabled PropertyChanged "Enabled" End Property Public Property Get Caption() As String Attribute Caption.VB_Description = "Returns/sets the text displayed in an object's title bar" Caption = m_caption End Property Public Property Let Caption(ByVal vNewValue As String) m_caption = vNewValue If m_caption > "" Then 'UserControl.Cls 'UserControl_Paint lblCaption.Visible = True lblCaption.Caption = " " + m_caption + " " UserControl.Refresh Else lblCaption.Visible = False 'UserControl.Cls 'UserControl_Paint UserControl.Refresh End If PropertyChanged "Caption" End Property Public Property Get Font() As Font Attribute Font.VB_Description = "Returns/sets the font to be used to display the caption and text for this control" Set Font = UserControl.Font End Property Public Property Set Font(ByVal New_Font As Font) Set UserControl.Font = New_Font Set lblCaption.Font = New_Font Set lblText.Font = New_Font PropertyChanged "Font" End Property Public Property Get Text() As String Attribute Text.VB_Description = "Returns/sets the text displayed within the inner bevel of the panel if panel is not used as a progress indicator" Text = m_text End Property Public Property Let Text(ByVal vNewValue As String) m_text = vNewValue DisplayText PropertyChanged "Text" End Property Public Property Get TextAlignment() As TextAlign Attribute TextAlignment.VB_Description = "Returns/sets the alignment of text in the panel" TextAlignment = m_TextAlignment End Property Public Property Let TextAlignment(ByVal vNewValue As TextAlign) If Not (m_TextAlignment = vNewValue) Then m_TextAlignment = vNewValue DisplayText End If PropertyChanged "TextAlignment" End Property Private Sub DisplayText() Timer.Enabled = False If m_FloodType > 0 Then If m_FloodShowPct And m_FloodType <> 5 Then lblText.Visible = True lblText.Caption = Str(m_FloodPercent) + "%" lblText.Top = (UserControl.Height / 2) - TextHeight("X") / 2 lblText.Width = TextWidth(Str(m_FloodPercent) + "%") lblText.Left = (UserControl.Width / 2) - TextWidth("100%") / 2 lblText.Alignment = 2 Else lblText.Visible = False End If Exit Sub End If lblText.Visible = False lblText.Caption = m_text If m_TextType = 1 Then lblText.Caption = Date If m_TextType = 2 Then lblText.Caption = Time: Timer.Enabled = True 'If m_TextType = 2 And UserControl.Extender.Parent.Ambient.UserMode Then Timer.Enabled = True lblText.Width = UserControl.Width - 120 Select Case m_TextAlignment Case 0 'lefttop lblText.Left = 60: lblText.Top = 60 lblText.Alignment = 0 Case 1 'leftmiddle lblText.Left = 60: lblText.Top = (UserControl.Height / 2) - TextHeight("X") / 2 lblText.Alignment = 0 Case 2 'leftbottom lblText.Left = 60: lblText.Top = UserControl.Height - 60 - TextHeight("X") lblText.Alignment = 0 Case 3 'centertop lblText.Left = 60: lblText.Top = 60 lblText.Alignment = 2 Case 4 'centermiddle lblText.Left = 60: lblText.Top = (UserControl.Height / 2) - TextHeight("X") / 2 lblText.Alignment = 2 Case 5 'centerbottom lblText.Left = 60: lblText.Top = UserControl.Height - 60 - TextHeight("X") lblText.Alignment = 2 Case 6 'righttop lblText.Left = 60: lblText.Top = 60 lblText.Alignment = 1 Case 7 'rightmiddle lblText.Left = 60: lblText.Top = (UserControl.Height / 2) - TextHeight("X") / 2 lblText.Alignment = 1 Case 8 'rightbottom lblText.Left = 60: lblText.Top = UserControl.Height - 60 - TextHeight("X") lblText.Alignment = 1 End Select lblText.Visible = True End Sub Private Sub DrawFlood() Dim fWidth As Integer, fHeight As Integer Dim StartLeft As Integer, ActiveBars As Integer fWidth = (UserControl.Width - 80) * (m_FloodPercent / 100) fHeight = (UserControl.Height - 80) * (m_FloodPercent / 100) Select Case m_FloodType Case 1 'left to right Flooder(0).FillColor = m_FloodColor Flooder(0).Height = UserControl.Height - 80 Flooder(0).Width = fWidth Flooder(0).Left = 40: Flooder(0).Top = 40 Case 2 'right to left Flooder(0).FillColor = m_FloodColor Flooder(0).Height = UserControl.Height - 80 Flooder(0).Width = fWidth Flooder(0).Left = 40 + UserControl.Width - 80 - fWidth: Flooder(0).Top = 40 Case 3 'top to bottom Flooder(0).FillColor = m_FloodColor Flooder(0).Height = fHeight Flooder(0).Width = UserControl.Width - 80 Flooder(0).Left = 40: Flooder(0).Top = 40 Case 4 'bottom to top Flooder(0).FillColor = m_FloodColor Flooder(0).Height = fHeight Flooder(0).Width = UserControl.Width - 80 Flooder(0).Left = 40: Flooder(0).Top = 40 + UserControl.Height - 80 - fHeight Case 5 ActiveBars = 20 * (m_FloodPercent / 100) - 1 For bar = 0 To 19 If bar <= ActiveBars Then Flooder(bar).FillColor = m_FloodColor Else Flooder(bar).FillColor = m_FloodBackColor End If Next End Select End Sub Public Property Get TextType() As TextTypes Attribute TextType.VB_Description = "Returns/sets a value to determine if text displayed is user-defined, current date, or current time" TextType = m_TextType End Property Public Property Let TextType(ByVal vNewValue As TextTypes) If Not (m_TextType = vNewValue) Then m_TextType = vNewValue DisplayText End If PropertyChanged "TextType" End Property Public Property Get FloodShowPct() As Boolean Attribute FloodShowPct.VB_Description = "Determines whether the current setting of the FloodPercent property is displayed when the panel is used as a progress indicator" FloodShowPct = m_FloodShowPct End Property Public Property Let FloodShowPct(ByVal vNewValue As Boolean) m_FloodShowPct = vNewValue If m_FloodType > 0 Then DisplayText PropertyChanged "FloodShowPct" End Property Public Property Get FloodType() As FloodTypes Attribute FloodType.VB_Description = "Determines if and how the panel is used as a progress indicator" FloodType = m_FloodType End Property Public Property Let FloodType(ByVal vNewValue As FloodTypes) m_FloodType = vNewValue DisplayText RemoveBars If m_FloodType > 0 And m_FloodType <> 5 Then Flooder(0).Visible = True: DrawFlood Else Flooder(0).Visible = False If m_FloodType = 5 Then Flooder(0).Visible = True: ShowBars: DrawFlood PropertyChanged "FloodType" End Property Public Property Get FloodPercent() As Integer Attribute FloodPercent.VB_Description = "Returns/set the percentage of the painted area inside the panel's inner bevel when the panel is used as a progress indicator" FloodPercent = m_FloodPercent End Property Public Property Let FloodPercent(ByVal vNewValue As Integer) If vNewValue < 0 Then vNewValue = 0 If vNewValue > 100 Then vNewValue = 100 m_FloodPercent = vNewValue If m_FloodType > 0 Then DisplayText: DrawFlood PropertyChanged "FloodPercent" End Property Public Property Get FloodColor() As OLE_COLOR Attribute FloodColor.VB_Description = "Returns/sets the color used to paint the area inside the panel's inner bevel when control is used as a progress indicator" FloodColor = m_FloodColor End Property Public Property Let FloodColor(ByVal vNewValue As OLE_COLOR) m_FloodColor = vNewValue If m_FloodType > 0 Then DisplayText: DrawFlood PropertyChanged "FloodColor" End Property Public Property Get FloodBackColor() As OLE_COLOR Attribute FloodBackColor.VB_Description = "Returns/sets color of inactive bars in Win95 style progress bar (only)" FloodBackColor = m_FloodBackColor End Property Public Property Let FloodBackColor(ByVal vNewValue As OLE_COLOR) m_FloodBackColor = vNewValue If m_FloodType > 0 Then DisplayText: DrawFlood PropertyChanged "FloodBackColor" End Property Public Property Get BackColor() As OLE_COLOR Attribute BackColor.VB_Description = "Returns/sets the background color of the object" BackColor = m_BackColor End Property Public Property Let BackColor(ByVal vNewValue As OLE_COLOR) m_BackColor = vNewValue UserControl.BackColor = m_BackColor lblCaption.BackColor = m_BackColor UserControl.Refresh PropertyChanged "BackColor" End Property Public Property Get ForeColor() As OLE_COLOR Attribute ForeColor.VB_Description = "Returns/sets color of caption and text for the control" ForeColor = m_ForeColor End Property Public Property Let ForeColor(ByVal vNewValue As OLE_COLOR) m_ForeColor = vNewValue UserControl.ForeColor = m_ForeColor lblCaption.ForeColor = m_ForeColor lblText.ForeColor = m_ForeColor UserControl.Refresh PropertyChanged "ForeColor" End Property Private Sub ShowBars() 'display windows95 style bars for meter Dim fBar95 As Integer 'change mode to pixels to get more even spacing UserControl.ScaleMode = vbPixels fBar95 = Int((UserControl.ScaleWidth - Int(80 / Screen.TwipsPerPixelX)) / 20) UserControl.ScaleMode = vbTwips 'convert to twips fBar95 = fBar95 * Screen.TwipsPerPixelX Flooder(0).Visible = False Flooder(0).FillColor = m_FloodBackColor Flooder(0).Height = UserControl.Height - 80 Flooder(0).Width = fBar95 - 20 Flooder(0).Left = 40: Flooder(0).Top = 40 For cnt = 1 To 19 Load Flooder(cnt) Flooder(cnt).FillColor = m_FloodBackColor Flooder(cnt).Height = UserControl.Height - 80 Flooder(cnt).Width = fBar95 - 20 Flooder(cnt).Left = 40 + (fBar95 * cnt): Flooder(cnt).Top = 40 Next For cnt = 0 To 19 Flooder(cnt).Visible = True Next End Sub Private Sub ResizeBars() 'resize windows95 style bars for meter when control is resized Dim fWidth95 As Integer, fBar95 As Integer 'change mode to pixels to get more even spacing UserControl.ScaleMode = vbPixels fWidth95 = Int((UserControl.ScaleWidth - Int(80 / Screen.TwipsPerPixelX)) / 20) fBar95 = Int((UserControl.ScaleWidth - Int(80 / Screen.TwipsPerPixelX)) / 20) UserControl.ScaleMode = vbTwips 'convert to twips fWidth95 = fWidth95 * Screen.TwipsPerPixelX fBar95 = fBar95 * Screen.TwipsPerPixelX For cnt = 0 To 19 Flooder(cnt).Visible = False Next Flooder(0).Height = UserControl.Height - 80 Flooder(0).Width = fBar95 - 20 For cnt = 1 To 19 Flooder(cnt).Height = UserControl.Height - 80 Flooder(cnt).Width = fBar95 - 20 Flooder(cnt).Left = 40 + (fWidth95 * cnt): Flooder(cnt).Top = 40 Next For cnt = 0 To 19 Flooder(cnt).Visible = True Next End Sub Private Sub RemoveBars() 'remove windows95 style bars for meter If Flooder().Count > 1 Then For cnt = 1 To Flooder().Count - 1 Unload Flooder(cnt) Next End If End Sub